
package cn.bluethink.eguan.model.okrtask;

import java.util.Date;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import cn.bluethink.eguan.model.core.EgTaskStatus;
import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.utils.DateTimeSerializer;

/**
 * @title 任务的关键结果（任务验收项）
 * @Copyright 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.1
 *
 * @note 修订历史： （1）liuxn于2018年8月14日构建初始版本0.1
 *       （2）giszyj@126.com于2018年10月06日删除task属性
 */
public class EgTaskKR {

	/**
	 * 关键结果主键
	 */
	private Long id;
	
	/**
	 * 关键结果所关联的任务
	 */
	private Long tid;

	/**
	 * 关键结果内容
	 */
	private String krContent;

	/**
	 * 关键结果备注
	 */
	private String remark;
	
	/**
	 * 关键项被指派人
	 */
	private EgUser douser;
	
	/**
	 * 评价，任务指派人对关键结果的评价
	 */
	private String evaluate;

	/**
	 * 打分（五分制，整数），任务指派人对关键结果进行打分
	 */
	private Integer score;

	/**
	 * 关键项截止时间
	 */
    @JsonSerialize(using = DateTimeSerializer.class)
	private Date etime;
	
	/**
	 * 用户完成关键项时间
	 */
    @JsonSerialize(using = DateTimeSerializer.class)
	private Date ftime;
	
	/**
	 * 任务关键项状态
	 */
	private Integer status;

	/**
	 * @since 1.0.0
	 * @roseuid 5B6D4F610029
	 */
	public EgTaskKR() {

	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getTid() {
		return tid;
	}

	public void setTid(Long tid) {
		this.tid = tid;
	}

	public String getKrContent() {
		return krContent;
	}

	public void setKrContent(String krContent) {
		this.krContent = krContent;
	}

	public String getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(String evaluate) {
		this.evaluate = evaluate;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public Date getEtime() {
		return etime;
	}

	public void setEtime(Date etime) {
		this.etime = etime;
	}
	
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public Date getFtime() {
		return ftime;
	}

	public void setFtime(Date ftime) {
		this.ftime = ftime;
	}

	public EgUser getDouser() {
		return douser;
	}

	public void setDouser(EgUser douser) {
		this.douser = douser;
	}

	/**
	 * 是否已被评分
	 * @return
	 */
	public boolean beenGraded() {
		return this.score != null && this.score > 0;
	}

	/**
	 * 状态是否一致
	 * @param krstatus
	 * @return
	 */
	public boolean bnullStatus(Integer krstatus) {
		if((this.status & EgTaskStatus.STATUS_DELAY) == EgTaskStatus.STATUS_DELAY) status = status^EgTaskStatus.STATUS_DELAY;
		if((krstatus & EgTaskStatus.STATUS_DELAY) == EgTaskStatus.STATUS_DELAY) krstatus = krstatus^EgTaskStatus.STATUS_DELAY;
		return this.status != null && this.status.equals(krstatus);
	}
}
